//
//  UserSecurityViewController.m
//  HuLaQuan
//
//  Created by hok on 1/19/16.
//  Copyright © 2016 Jianghao. All rights reserved.
//

#import "UserSecurityViewController.h"

//cells
#import "UserCenterNewCell.h"


#import "ModifyCheckUserPasswordController.h"
@interface UserSecurityViewController ()

@property (nonatomic,strong) NSArray *items;
@end


static NSString * const UserCenterCellIdentifier = @"UserCenterNewCellIdentifier";

@implementation UserSecurityViewController

- (NSArray *)items
{
    if(!_items) _items=@[@[@"修改登录密码",@"忘记登录密码"],@[@"修改支付密码",@"忘记支付密码"]];
    return _items;
}
- (void)setupUI
{
    [self.tableView registerNib:[UserCenterNewCell nib] forCellReuseIdentifier:UserCenterCellIdentifier];
    
    
    self.tableView.backgroundColor = UIColorFromRGBA(kBackgroundColor, 1.0);
    
    [self setupNavBackButton];
    
    self.title = @"安全管理";
    
    
}
#pragma mark - TableView Delegate
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    if (section == 0) {
        return 0.000001;
    }else{
        return kUserCenterSectionHeaderHeight;
    }
    
}
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    return 0.000001;
}
/*- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
 {
 CGFloat tableHeight = [tableView headerViewForSection:section].frame.size.height;
 NSLog(@"%f",tableHeight);
 /* if (section!=0)
 {
 UIView * head=[[UIView alloc]initWithFrame:CGRectMake(0, 0, 320, 2)];
 return head ;
 }
 else
 {
 UIView * head=[[UIView alloc]initWithFrame:CGRectMake(0, 0, 320, 0)];
 return head ;
 
 }
 UIView * head=[[UIView alloc]initWithFrame:CGRectMake(0, 0, 320, 0)];
 return head ;
 }*/
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return kUserCenterCellHeight;
    
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 2;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    
    return [self.items[section] count];
    
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
   
            
    UserCenterNewCell *cell = [tableView dequeueReusableCellWithIdentifier:UserCenterCellIdentifier
                                                              forIndexPath:indexPath];

    
    cell.title.text = self.items[indexPath.section][indexPath.row];
    
    
   
    return cell;
    
            
            
    
    
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    

    
    
    switch (indexPath.section) {
        case 0:
        {
            switch (indexPath.row) {
                case 0:
                    [self performSegueWithIdentifier:@"ShowModifyUserPasswordFromSecurity" sender:self];
                    break;
                case 1:
                    [self performSegueWithIdentifier:@"ShowForgetUserPasswordFromSecurity" sender:self];
                    break;
                    
                    
                default:
                    break;
            }
        }
            
        
            break;
        case 1:
        {
            switch (indexPath.row) {
                case 0:
                    [self performSegueWithIdentifier:@"ShowModifyPaymentPasswordFromSecurity" sender:self];
                    
                    break;
                case 1:
                    [self performSegueWithIdentifier:@"ShowForgetPayPasswordFromSecurity" sender:self];
                    break;
                    
                    
                default:
                    break;
            }
        }
            break;
            
        default:
            break;
    }
}


- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
    
    if ([[segue identifier] isEqualToString:@"ShowModifyUserPasswordFromSecurity"]) {
        ModifyCheckUserPasswordController *controller = (ModifyCheckUserPasswordController*) [segue destinationViewController];
        controller.type = UserPassword;
        controller.titleOfNav = @"验证登录密码";
        controller.titleOfPassword = kCheckUserPasswordHint;
        return;
    }
    if ([[segue identifier] isEqualToString:@"ShowModifyPaymentPasswordFromSecurity"]) {
      //  CheckInputPasswordViewController *controller = (CheckInputPasswordViewController*) [segue destinationViewController];
     //   controller.type = PayPassword;
        return;
    }
}



@end
